--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit f6158ba4df055d3b1ec8cefdd6332a0786193781
Parents : 503ea58
Author : Mark Qvist <bc7291552be7a58f361522990465165c>
Date : 2026-05-21T00:38:08+02:00
Added custom nick color theme option
Changes
2 files changed, 26 insertions(+), 4 deletions(-)
Diff
diff --git a/nomadnet/NomadNetworkApp.py b/nomadnet/NomadNetworkApp.py
index e18663d..3e9b068 100644
--- a/nomadnet/NomadNetworkApp.py
+++ b/nomadnet/NomadNetworkApp.py
@@ -157,6 +157,7 @@ class NomadNetworkApp:
self.rrc_filter_loaded_history = True
self.rrc_ephemeral_notices = 600
self.rrc_nick_colors = True
+ self.rrc_nick_colors_theme = None
self.rrc_ui_justify_msgs = True
self.rrc_ui_space_msgs = False
self.rrc_ui_render_markdown = True
@@ -950,6 +951,20 @@ class NomadNetworkApp:
except Exception: value = True
self.rrc_nick_colors = value
+ if option == "nick_colors_theme":
+ try:
+ colors = self.config["rrc"].as_list(option)
+ nick_colors_theme = []
+ for c in colors:
+ if len(c) == 6:
+ try: bytes.fromhex(c)
+ except: continue
+ nick_colors_theme.append(c)
+ self.rrc_nick_colors_theme = nick_colors_theme
+ except Exception as e:
+ RNS.log(f"Could not load custom nick colors theme: {e}", RNS.LOG_WARNING)
+ self.rrc_nick_colors_theme = None
+
if option == "render_markdown":
try: value = self.config["rrc"].as_bool(option)
except Exception: value = True
@@ -1306,6 +1321,11 @@ nick_colors = yes
justify_msgs = yes
space_msgs = no
+# You can configure your own color theme
+# for nick color assignment
+# nick_colors_theme = f68787, 00c394, d59e00, ...
+
+
[node]
# Whether to enable node hosting
diff --git a/nomadnet/ui/textui/Channels.py b/nomadnet/ui/textui/Channels.py
index 07e33fb..143dd0d 100644
--- a/nomadnet/ui/textui/Channels.py
+++ b/nomadnet/ui/textui/Channels.py
@@ -909,12 +909,14 @@ class _ChatLinkDelegate:
except Exception as e:
RNS.log("Could not open page link: "+str(e), RNS.LOG_ERROR)
-def get_nick_color(sender_hash, theme, shift=15):
+def get_nick_color(sender_hash, theme, app, shift=15):
+ if app.rrc_nick_colors_theme: nick_colors = app.rrc_nick_colors_theme
+ else: nick_colors = theme["nick_colors"]
if type(sender_hash) == str:
try: sender_hash = sender_hash.encode("utf-8")
except: pass
if not type(sender_hash) == bytes: return theme["nick_peer"]
- return theme["nick_colors"][(int.from_bytes(sender_hash)+shift)%len(theme["nick_colors"])]
+ return nick_colors[(int.from_bytes(sender_hash)+shift)%len(nick_colors)]
room_nick_src_cache = {}
mdc = MarkdownToMicron(max_width=80, syntax_highlighter=SyntaxHighlighter(), url_scope=None)
@@ -978,7 +980,7 @@ def _message_widget(app, hub, m, link_delegate=None):
if ms.startswith("irc_mention"):
if not app.rrc_nick_colors: message_body += f"`!`F{t['mention']}{mb}`f`!"
else:
- try: message_body += f"`!`FT{get_nick_color(room_nick_src_cache[m.nick], t)}{mb}`f`!"
+ try: message_body += f"`!`FT{get_nick_color(room_nick_src_cache[m.nick], t, app)}{mb}`f`!"
except: message_body += f"`!`F{t['mention']}{mb}`f`!"
elif ms.startswith("link_"):
@@ -998,7 +1000,7 @@ def _message_widget(app, hub, m, link_delegate=None):
mbo = mdc.format_block(strip_escaped_micron(mb)) if app.rrc_ui_render_markdown else strip_escaped_micron(mb)
message_body += strip_non_formatting_tags(mbo)
- if app.rrc_nick_colors: nick_attr = f"`FT{get_nick_color(m.src, t)}"
+ if app.rrc_nick_colors: nick_attr = f"`FT{get_nick_color(m.src, t, app)}"
else: nick_attr = f"`F{t['nick_self']}" if own else f"`F{t['nick_peer']}"
irc_ts = f"`F{t['ts']}"
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────